package com.bw.user.controller;


import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.bw.core.result.ResponseResult;
import com.bw.user.service.TbTaobaoAuthService;
import com.bw.user.vo.TaoBaoAuthVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 淘宝认证$信息表 前端控制器
 * </p>
 *
 * @author lv
 * @since 2021-03-23
 */
@RestController
@RequestMapping("/tb-taobao-auth")
public class TbTaobaoAuthController {

    @Autowired
    private TbTaobaoAuthService taobaoAuthService;

    @PostMapping("/toabao")
    public ResponseResult taobao(@RequestBody TaoBaoAuthVo taoBaoAuthVo)
    {
        if (ObjectUtil.isNull(taoBaoAuthVo)){
            return ResponseResult.error("对象为空");
        }

        if (StrUtil.isEmpty(taoBaoAuthVo.getTaobaoAccount())) {
            return ResponseResult.error("淘宝用户名不能为空");
        }
        if (StrUtil.isEmpty(taoBaoAuthVo.getTaobaoPassword())) {
            return ResponseResult.error("淘宝密码不能为空");
        }

        return taobaoAuthService.taobao(taoBaoAuthVo);
    }

}
